package www.rlicker.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import www.rlicker.model.UserEmployDuration;
import www.rlicker.mybatis.Criteria;
import www.rlicker.mybatis.PageResult;
import www.rlicker.service.IUserEmployDurationService;
import www.rlicker.utils.StringUtil;

@Controller
@RequestMapping(value="/useremploy")
public class UserEmployDurationController {

	@Autowired
	private IUserEmployDurationService  service;
	
	@RequestMapping("/showlist")
	public String showlist(){
		return "useremploy/userEmployList";
	}
	
	@RequestMapping("/querypage")
	@ResponseBody
	public PageResult queryPage(HttpServletRequest request){
		 Criteria<UserEmployDuration> param = new Criteria<UserEmployDuration>();
		 if (!StringUtil.isNullOrBlank(request.getParameter("phone"))) {
			 param.addParam("phone", request.getParameter("phone"));
		 }
		 if (!StringUtil.isNullOrBlank(request.getParameter("startDurationNu"))) {
			 param.addParam("startDurationNu", request.getParameter("startDurationNu"));
		 }
		 if (!StringUtil.isNullOrBlank(request.getParameter("endDurationNum"))) {
			 param.addParam("endDurationNum", request.getParameter("endDurationNum"));
		 }
         if (!StringUtil.isNullOrBlank(request.getParameter("startOpenCount"))) {
          	 param.addParam("startOpenCount", request.getParameter("startOpenCount"));
         }
         if (!StringUtil.isNullOrBlank(request.getParameter("endOpenCount"))) {
        	 param.addParam("endOpenCount", request.getParameter("endOpenCount"));
         }
 	     if (!StringUtil.isNullOrBlank(request.getParameter("pageNumber"))) {
	    	param.addParam("startIndex", Integer.parseInt(request.getParameter("pageNumber")));
	     }
	     if (!StringUtil.isNullOrBlank(request.getParameter("pageSize"))) {
	    	param.addParam("endPage", Integer.parseInt(request.getParameter("pageSize")));
	     }
	     List<Map<String,Object>> list = service.queryPage(param);
	     PageResult pageResult = new PageResult();
	     pageResult.setTotal(service.queryPageCount(param));
		 pageResult.setRows(list);
		 return pageResult;	
	}
	
	@RequestMapping("/duration")
	public String showDuration(){
		return "useremploy/durationCount";
	}
	
	@RequestMapping("/frequency")
	public String showFrequency(){
		return "useremploy/frequencyCount";
	}
	
	
}
